garmin_txt.cc
garmin_xt.cc
gdb.cc
+ geocache.cc
geojson.cc
globalsat_sport.cc
gpssim.cc
gbser.h
gbser_private.h
gdb.h
+ geocache.h
geojson.h
globalsat_sport.h
gpx.h
#include <Qt> // for CaseInsensitive
#include <QtGlobal> // for QForeachContainer, qMakeForeachContainer, foreach, qint64
+#include "geocache.h" // for Geocache
#include "formspec.h" // for FormatSpecificData
#include "inifile.h" // for inifile_t
#include "session.h" // for session_t
fix_pps
};
-enum status_type {
- status_unknown=0,
- status_true,
- status_false
-};
-
-/*
- * Extended data if waypoint happens to represent a geocache. This is
- * totally voluntary data...
- */
-
-enum geocache_type {
- gt_unknown = 0,
- gt_traditional,
- gt_multi,
- gt_virtual,
- gt_letterbox,
- gt_event,
- gt_surprise,
- gt_webcam,
- gt_earth,
- gt_locationless,
- gt_benchmark, /* Extension to Groundspeak for GSAK */
- gt_cito,
- gt_ape,
- gt_mega,
- gt_wherigo
-};
-
-enum geocache_container {
- gc_unknown = 0,
- gc_micro,
- gc_other,
- gc_regular,
- gc_large,
- gc_virtual,
- gc_small
-};
-
-class utf_string
-{
-public:
- utf_string() = default;
- utf_string(bool html, QString str) :
- is_html{html},
- utfstring{std::move(str)}
- {}
- bool is_html{false};
- QString utfstring;
-};
-
-class geocache_data
-{
-public:
- geocache_data() :
- id(0),
- type(gt_unknown),
- container(gc_unknown),
- diff(0),
- terr(0),
- is_archived(status_unknown),
- is_available(status_unknown),
- is_memberonly(status_unknown),
- has_customcoords(status_unknown),
- placer_id(0),
- favorite_points(0)
- {}
- long long id; /* The decimal cache number */
- geocache_type type:5;
- geocache_container container:4;
- unsigned int diff:6; /* (multiplied by ten internally) */
- unsigned int terr:6; /* (likewise) */
- status_type is_archived:2;
- status_type is_available:2;
- status_type is_memberonly:2;
- status_type has_customcoords:2;
- gpsbabel::DateTime exported;
- gpsbabel::DateTime last_found;
- QString placer; /* Placer name */
- int placer_id; /* Placer id */
- QString hint; /* all these UTF8, XML entities removed, May be not HTML. */
- utf_string desc_short;
- utf_string desc_long;
- int favorite_points;
- QString personal_note;
-};
-
class gb_color
{
public:
class Waypoint
{
private:
- static geocache_data empty_gc_data;
+ static Geocache empty_gc_data;
public:
float power; /* watts, as measured by cyclists */
float temperature; /* Degrees celsius */
float odometer_distance; /* Meters */
- geocache_data* gc_data;
+ Geocache* gc_data;
FormatSpecificDataList fs;
const session_t* session; /* pointer to a session struct */
void* extra_data; /* Extra data added by, say, a filter. */
gpsbabel::DateTime GetCreationTime() const;
void SetCreationTime(const gpsbabel::DateTime& t);
void SetCreationTime(qint64 t, qint64 ms = 0);
- geocache_data* AllocGCData();
+ Geocache* AllocGCData();
int EmptyGCData() const;
};
using ff_writeposn = void (*)(Waypoint*);
using ff_readposn = Waypoint* (*)(posn_status*);
-geocache_type gs_mktype(const QString& t);
-geocache_container gs_mkcont(const QString& t);
-
/*
* All shortname functions take a shortname handle as the first arg.
* This is an opaque pointer. Callers must not fondle the contents of it.
bool gpsbabel_testmode();
gpsbabel::DateTime current_time();
QDateTime dotnet_time_to_qdatetime(long long dotnet);
-QString get_cache_icon(const Waypoint* waypointp);
-QString gs_get_cachetype(geocache_type t);
-QString gs_get_container(geocache_container t);
-QString strip_html(const utf_string*);
+QString strip_html(const QString& utfstring);
QString strip_nastyhtml(const QString& in);
QString convert_human_date_format(const char* human_datef); /* "MM,YYYY,DD" -> "%m,%Y,%d" */
QString convert_human_time_format(const char* human_timef); /* "HH+mm+ss" -> "%H+%M+%S" */
*/
-#include <algorithm> // for stable_sort
-#include <cstdio> // for snprintf
-#include <cstring> // for memset, strncpy
+#include "duplicate.h"
+
+#include <algorithm> // for stable_sort
+#include <cstdio> // for snprintf
+#include <cstring> // for memset, strncpy
-#include <QDateTime> // for QDateTime
-#include <QtGlobal> // for foreach
+#include <QDateTime> // for QDateTime
#include "defs.h"
-#include "duplicate.h"
-#include "src/core/datetime.h" // for DateTime
+#include "geocache.h" // for Geocache
+#include "src/core/datetime.h" // for DateTime
#if FILTERS_ENABLED
#ifndef DUPLICATE_H_INCLUDED_
#define DUPLICATE_H_INCLUDED_
-#include <QVector> // for QVector
+#include <QString> // for QString
+#include <QVector> // for QVector
#include "defs.h" // for ARGTYPE_BOOL, ARG_NOMINMAX, Waypoint (ptr only)
#include "filter.h" // for Filter
*/
-#include <cctype> // for isalpha, toupper
-#include <climits> // for INT_MAX
-#include <cmath> // for atan2, floor, sqrt
-#include <csetjmp> // for setjmp
-#include <cstdio> // for fprintf, fflush, snprintf, snprintf
-#include <cstdlib> // for strtol
-#include <cstring> // for memcpy, strlen, strncpy, strchr
-#include <ctime> // for time_t
-
-#include <QByteArray> // for QByteArray
-#include <QChar> // for QChar
-#include <QString> // for QString
-#include <Qt> // for CaseInsensitive
-#include <QtGlobal> // for qPrintable, foreach
+#include <cctype> // for isalpha, toupper
+#include <climits> // for INT_MAX
+#include <cmath> // for atan2, floor, sqrt
+#include <csetjmp> // for setjmp
+#include <cstdio> // for fprintf, fflush, snprintf, snprintf
+#include <cstdlib> // for strtol
+#include <cstring> // for memcpy, strlen, strncpy, strchr
+#include <ctime> // for time_t
+
+#include <QByteArray> // for QByteArray
+#include <QChar> // for QChar
+#include <QString> // for QString
+#include <QVector> // for QVector
+#include <Qt> // for CaseInsensitive
+#include <QtGlobal> // for qPrintable, foreach
#include "defs.h"
-#include "cet_util.h" // for cet_convert_init, cet_cs_vec_utf8
-#include "format.h" // for Format
-#include "garmin_device_xml.h" // for gdx_get_info, gdx_info, gdx_file, gdx_jmp_buf
-#include "garmin_fs.h" // for garmin_fs_garmin_after_read, garmin_fs_garmin_before_write
-#include "garmin_tables.h" // for gt_find_icon_number_from_desc, PCX, gt_find_desc_from_icon_number
-#include "grtcirc.h" // for DEG
-#include "jeeps/gps.h"
-#include "jeeps/gpsserial.h"
-#include "src/core/datetime.h" // for DateTime
-#include "vecs.h" // for Vecs
+#include "cet_util.h" // for cet_convert_init, cet_cs_vec_utf8
+#include "format.h" // for Format
+#include "garmin_device_xml.h" // for gdx_get_info, gdx_info, gdx_file, gdx_jmp_buf
+#include "garmin_fs.h" // for garmin_fs_garmin_after_read, garmin_fs_garmin_before_write
+#include "garmin_tables.h" // for gt_find_icon_number_from_desc, PCX, gt_find_desc_from_icon_number
+#include "geocache.h" // for Geocache, Geocache::type_t, Geocache...
+#include "grtcirc.h" // for DEG
+#include "jeeps/gpsapp.h" // for GPS_Set_Baud_Rate, GPS_Init, GPS_Pre...
+#include "jeeps/gpscom.h" // for GPS_Command_Get_Lap, GPS_Command_Get...
+#include "jeeps/gpsdevice.h" // for gpsdevh
+#include "jeeps/gpsmem.h" // for GPS_Track_Del, GPS_Way_Del, GPS_Pvt_Del
+#include "jeeps/gpsport.h" // for int32
+#include "jeeps/gpsprot.h" // for gps_waypt_type, gps_category_type
+#include "jeeps/gpssend.h" // for GPS_SWay, GPS_PWay, GPS_STrack, GPS_...
+#include "jeeps/gpsserial.h" // for DEFAULT_BAUD
+#include "jeeps/gpsutil.h" // for GPS_User, GPS_Enable_Diagnose, GPS_E...
+#include "src/core/datetime.h" // for DateTime
+#include "vecs.h" // for Vecs
+
#define MYNAME "GARMIN"
static const char* portname;
get_gc_info(const Waypoint* wpt)
{
if (global_opts.smart_names) {
- if (wpt->gc_data->type == gt_virtual) {
+ if (wpt->gc_data->type == Geocache::type_t::gt_virtual) {
return "V ";
}
- if (wpt->gc_data->type == gt_unknown) {
+ if (wpt->gc_data->type == Geocache::type_t::gt_unknown) {
return "? ";
}
- if (wpt->gc_data->type == gt_multi) {
+ if (wpt->gc_data->type == Geocache::type_t::gt_multi) {
return "Mlt ";
}
- if (wpt->gc_data->type == gt_earth) {
+ if (wpt->gc_data->type == Geocache::type_t::gt_earth) {
return "EC ";
}
- if (wpt->gc_data->type == gt_event) {
+ if (wpt->gc_data->type == Geocache::type_t::gt_event) {
return "Ev ";
}
- if (wpt->gc_data->container == gc_micro) {
+ if (wpt->gc_data->container == Geocache::container_t::gc_micro) {
return "M ";
}
- if (wpt->gc_data->container == gc_small) {
+ if (wpt->gc_data->container == Geocache::container_t::gc_small) {
return "S ";
}
}
if (deficon) {
icon = gt_find_icon_number_from_desc(deficon, PCX);
} else {
- if (!get_cache_icon(wpt).isEmpty()) {
- icon = gt_find_icon_number_from_desc(get_cache_icon(wpt), PCX);
+ if (!wpt->gc_data->get_icon().isEmpty()) {
+ icon = gt_find_icon_number_from_desc(wpt->gc_data->get_icon(), PCX);
} else {
icon = gt_find_icon_number_from_desc(wpt->icon_descr, PCX);
}
#include "defs.h"
#include "gbfile.h" // for gbfclose, gbfopen, gbfputs, gbfile
+#include "geocache.h" // for Geocache, Geocache::container_t, Geo...
#include "src/core/file.h" // for File
static QXmlStreamReader reader;
static QString geo_read_fname;
-static geocache_container wpt_container(const QString&);
+static Geocache::container_t wpt_container(const QString&);
static void GeoReadLoc()
{
}
}
-geocache_container wpt_container(const QString& args)
+Geocache::container_t wpt_container(const QString& args)
{
- geocache_container v;
+ Geocache::container_t v;
switch (args.toInt()) {
case 1:
- v = gc_unknown;
+ v = Geocache::container_t::gc_unknown;
break;
case 2:
- v = gc_micro;
+ v = Geocache::container_t::gc_micro;
break;
case 3:
- v = gc_regular;
+ v = Geocache::container_t::gc_regular;
break;
case 4:
- v = gc_large;
+ v = Geocache::container_t::gc_large;
break;
case 5:
- v = gc_virtual;
+ v = Geocache::container_t::gc_virtual;
break;
case 6:
- v = gc_other;
+ v = Geocache::container_t::gc_other;
break;
case 8:
- v = gc_small;
+ v = Geocache::container_t::gc_small;
break;
default:
- v = gc_unknown;
+ v = Geocache::container_t::gc_unknown;
break;
}
return v;
int v = 1;
switch (waypointp->gc_data->container) {
- case gc_unknown:
+ case Geocache::container_t::gc_unknown:
v = 1;
break;
- case gc_micro:
+ case Geocache::container_t::gc_micro:
v = 2;
break;
- case gc_regular:
+ case Geocache::container_t::gc_regular:
v = 3;
break;
- case gc_large:
+ case Geocache::container_t::gc_large:
v = 4;
break;
- case gc_virtual:
+ case Geocache::container_t::gc_virtual:
v = 5;
break;
- case gc_other:
+ case Geocache::container_t::gc_other:
v = 6;
break;
- case gc_small:
+ case Geocache::container_t::gc_small:
v = 8;
break;
default:
--- /dev/null
+/*
+ Copyright (C) 2002-2023 Robert Lipe, robertlipe+source@gpsbabel.org
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ */
+
+#include "geocache.h"
+
+#include <QString> // for QString
+#include <QVector> // for QVector
+#include <Qt> // for CaseInsensitive
+
+#include "defs.h" // for strip_html, global_options, global_opts
+
+
+const QVector<Geocache::type_mapping> Geocache::type_map = {
+ {type_t::gt_traditional, "Traditional Cache" },
+ {type_t::gt_traditional, "Traditional" }, /* opencaching.de */
+ {type_t::gt_multi, "Multi-cache" },
+ {type_t::gt_multi, "Multi" }, /* opencaching.de */
+ {type_t::gt_virtual, "Virtual Cache" },
+ {type_t::gt_virtual, "Virtual" }, /* opencaching.de */
+ {type_t::gt_event, "Event Cache" },
+ {type_t::gt_event, "Event" }, /* opencaching.de */
+ {type_t::gt_webcam, "Webcam Cache" },
+ {type_t::gt_webcam, "Webcam" }, /* opencaching.de */
+ {type_t::gt_surprise, "Unknown Cache" },
+ {type_t::gt_earth, "Earthcache" },
+ {type_t::gt_earth, "Earth" }, /* opencaching.de */
+ {type_t::gt_cito, "Cache In Trash Out Event" },
+ {type_t::gt_letterbox, "Letterbox Hybrid" },
+ {type_t::gt_locationless, "Locationless (Reverse) Cache" },
+ {type_t::gt_ape, "Project APE Cache" },
+ {type_t::gt_mega, "Mega-Event Cache" },
+ {type_t::gt_wherigo, "Wherigo Cache" },
+
+ {type_t::gt_benchmark, "Benchmark" } /* Not Groundspeak; for GSAK */
+};
+
+const QVector<Geocache::container_mapping> Geocache::container_map = {
+ {container_t::gc_other, "Unknown" },
+ {container_t::gc_other, "Other" }, /* Synonym on read. */
+ {container_t::gc_micro, "Micro" },
+ {container_t::gc_regular, "Regular" },
+ {container_t::gc_large, "Large" },
+ {container_t::gc_small, "Small" },
+ {container_t::gc_virtual, "Virtual" }
+};
+
+QString Geocache::UtfString::strip_html() const
+{
+ return is_html? ::strip_html(utf_string) : utf_string;
+}
+
+void Geocache::set_type(const QString& type_name)
+{
+ for (const auto& map_entry : type_map) {
+ if (!type_name.compare(map_entry.name,Qt::CaseInsensitive)) {
+ type = map_entry.type;
+ return;
+ }
+ }
+ type = type_t::gt_unknown;
+}
+
+QString Geocache::get_type() const
+{
+ for (const auto& map_entry : type_map) {
+ if (type == map_entry.type) {
+ return map_entry.name;
+ }
+ }
+ return "Unknown";
+}
+
+void Geocache::set_container(const QString& container_name)
+{
+ for (const auto& map_entry : container_map) {
+ if (!container_name.compare(map_entry.name,Qt::CaseInsensitive)) {
+ container = map_entry.container;
+ return;
+ }
+ }
+ container = container_t::gc_unknown;
+}
+
+QString Geocache::get_container() const
+{
+ for (const auto& map_entry : container_map) {
+ if (container == map_entry.container) {
+ return map_entry.name;
+ }
+ }
+ return "Unknown";
+}
+
+/*
+ * Return a QString that is suitable for icon lookup based on geocache
+ * attributes. The strings used are those present in a GPX file from
+ * geocaching.com. Thus we sort of make all the other formats do lookups
+ * based on these strings.
+ */
+QString Geocache::get_icon() const
+{
+ if (!global_opts.smart_icons) {
+ return nullptr;
+ }
+
+ /*
+ * For icons, type overwrites container. So a multi-micro will
+ * get the icons for "multi".
+ */
+ switch (type) {
+ case type_t::gt_virtual:
+ return "Virtual cache";
+ case type_t::gt_multi:
+ return "Multi-Cache";
+ case type_t::gt_event:
+ return "Event Cache";
+ case type_t::gt_surprise:
+ return "Unknown Cache";
+ case type_t::gt_webcam:
+ return "Webcam Cache";
+ default:
+ break;
+ }
+
+ switch (container) {
+ case container_t::gc_micro:
+ return "Micro-Cache";
+ default:
+ break;
+ }
+
+ if (diff > 1) {
+ return "Geocache";
+ }
+
+ return nullptr;
+}
--- /dev/null
+/*
+ Copyright (C) 2002-2023 Robert Lipe, robertlipe+source@gpsbabel.org
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ */
+#ifndef GEOCACHE_H_INCLUDED_
+#define GEOCACHE_H_INCLUDED_
+
+#include <QString> // for QString
+#include <QVector> // for QVector
+
+#include "src/core/datetime.h" // for DateTime
+
+
+/*
+ * Extended data if waypoint happens to represent a geocache. This is
+ * totally voluntary data...
+ */
+class Geocache
+{
+public:
+
+ /* Types */
+
+ enum class type_t {
+ gt_unknown = 0,
+ gt_traditional,
+ gt_multi,
+ gt_virtual,
+ gt_letterbox,
+ gt_event,
+ gt_surprise,
+ gt_webcam,
+ gt_earth,
+ gt_locationless,
+ gt_benchmark, /* Extension to Groundspeak for GSAK */
+ gt_cito,
+ gt_ape,
+ gt_mega,
+ gt_wherigo
+ };
+
+ enum class container_t {
+ gc_unknown = 0,
+ gc_micro,
+ gc_other,
+ gc_regular,
+ gc_large,
+ gc_virtual,
+ gc_small
+ };
+
+ enum class status_t {
+ gs_unknown = 0,
+ gs_true,
+ gs_false
+ };
+
+ class UtfString
+ {
+ public:
+
+ QString strip_html() const;
+
+ bool is_html{false};
+ QString utf_string;
+ };
+
+ /* Special Member Functions */
+
+ Geocache() :
+ id(0),
+ type(type_t::gt_unknown),
+ container(container_t::gc_unknown),
+ diff(0),
+ terr(0),
+ is_archived(status_t::gs_unknown),
+ is_available(status_t::gs_unknown),
+ is_memberonly(status_t::gs_unknown),
+ has_customcoords(status_t::gs_unknown),
+ placer_id(0),
+ favorite_points(0)
+ {}
+
+ /* Member Functions */
+
+ void set_type(const QString& type_name);
+ QString get_type() const;
+ void set_container(const QString& container_name);
+ QString get_container() const;
+ QString get_icon() const;
+
+ /* Data Members */
+
+ long long id; /* The decimal cache number */
+ type_t type:5;
+ container_t container:4;
+ unsigned int diff:6; /* (multiplied by ten internally) */
+ unsigned int terr:6; /* (likewise) */
+ status_t is_archived:2;
+ status_t is_available:2;
+ status_t is_memberonly:2;
+ status_t has_customcoords:2;
+ gpsbabel::DateTime exported;
+ gpsbabel::DateTime last_found;
+ QString placer; /* Placer name */
+ int placer_id; /* Placer id */
+ QString hint; /* all these UTF8, XML entities removed, May be not HTML. */
+ UtfString desc_short;
+ UtfString desc_long;
+ int favorite_points;
+ QString personal_note;
+
+private:
+
+ /* Types */
+
+ struct type_mapping {
+ type_t type;
+ QString name;
+ };
+
+ struct container_mapping {
+ container_t container;
+ QString name;
+ };
+
+ /* Constants */
+
+ static const QVector<type_mapping> type_map;
+ static const QVector<container_mapping> container_map;
+};
+#endif // GEOCACHE_H_INCLUDED_
*/
-#include <cmath> // for lround
-#include <cstdio> // for sscanf
-#include <cstdlib> // for strtod
-#include <cstring> // for strchr, strncpy
-
-#include <QDate> // for QDate
-#include <QDateTime> // for QDateTime
-#include <QHash> // for QHash
-#include <QIODevice> // for QIODevice, operator|, QIODevice::ReadOnly, QIODevice::Text, QIODevice::WriteOnly
-#include <QLatin1Char> // for QLatin1Char
-#include <QLatin1String> // for QLatin1String
-#include <QString> // for QString, QStringLiteral, operator+, operator==
-#include <QStringList> // for QStringList
-#include <QStringView> // for QStringView
-#include <QTime> // for QTime
-#include <QVersionNumber> // for QVersionNumber
-#include <QXmlStreamAttribute> // for QXmlStreamAttribute
-#include <QXmlStreamAttributes> // for QXmlStreamAttributes
-#include <QXmlStreamNamespaceDeclaration> // for QXmlStreamNamespaceDeclaration
-#include <QXmlStreamNamespaceDeclarations> // for QXmlStreamNamespaceDeclarations
-#include <QXmlStreamReader> // for QXmlStreamReader, QXmlStreamReader::Characters, QXmlStreamReader::EndDocument, QXmlStreamReader::EndElement, QXmlStreamReader::Invalid, QXmlStreamReader::StartElement
-#include <Qt> // for CaseInsensitive, UTC
-#include <QtGlobal> // for qAsConst, QAddConst<>::Type
+#include "gpx.h"
+
+#include <cmath> // for lround
+#include <cstdio> // for sscanf
+#include <cstring> // for strchr, strncpy
+
+#include <QByteArray> // for QByteArray
+#include <QDate> // for QDate
+#include <QDateTime> // for QDateTime
+#include <QHash> // for QHash
+#include <QIODevice> // for QIODevice, operator|, QIODevice::ReadOnly, QIODevice::Text, QIODevice::WriteOnly
+#include <QLatin1Char> // for QLatin1Char
+#include <QLatin1String> // for QLatin1String
+#include <QString> // for QString, QStringLiteral, operator+, operator==
+#include <QStringList> // for QStringList
+#include <QStringView> // for QStringView
+#include <QTime> // for QTime
+#include <QVersionNumber> // for QVersionNumber
+#include <QXmlStreamAttribute> // for QXmlStreamAttribute
+#include <QXmlStreamAttributes> // for QXmlStreamAttributes
+#include <QXmlStreamNamespaceDeclaration> // for QXmlStreamNamespaceDeclaration
+#include <QXmlStreamNamespaceDeclarations> // for QXmlStreamNamespaceDeclarations
+#include <QXmlStreamReader> // for QXmlStreamReader, QXmlStreamReader::Characters, QXmlStreamReader::EndDocument, QXmlStreamReader::EndElement, QXmlStreamReader::Invalid, QXmlStreamReader::StartElement
+#include <Qt> // for CaseInsensitive, UTC
+#include <QtGlobal> // for qAsConst, QAddConst<>::Type
#include "defs.h"
-#include "gpx.h"
-#include "garmin_fs.h" // for garmin_fs_xml_convert, garmin_fs_xml_fprint, GMSD_FIND
-#include "garmin_tables.h" // for gt_color_index_by_rgb, gt_color_name, gt_color_value_by_name
-#include "src/core/datetime.h" // for DateTime
-#include "src/core/file.h" // for File
-#include "src/core/logging.h" // for Warning, Fatal
-#include "src/core/xmlstreamwriter.h" // for XmlStreamWriter
-#include "src/core/xmltag.h" // for xml_tag, fs_xml, fs_xml_alloc, free_gpx_extras
+#include "garmin_fs.h" // for garmin_fs_xml_convert, garmin_fs_xml_fprint, GMSD_FIND
+#include "garmin_tables.h" // for gt_color_index_by_rgb, gt_color_name, gt_color_value_by_name
+#include "geocache.h" // for Geocache, Geocache::UtfSt...
+#include "src/core/datetime.h" // for DateTime
+#include "src/core/file.h" // for File
+#include "src/core/logging.h" // for Warning, Fatal
+#include "src/core/xmlstreamwriter.h" // for XmlStreamWriter
+#include "src/core/xmltag.h" // for xml_tag, fs_xml, fs_xml_alloc, free_gpx_extras
#define MYNAME "GPX"
void
GpxFormat::tag_gs_cache(const QXmlStreamAttributes& attr) const
{
- geocache_data* gc_data = wpt_tmp->AllocGCData();
+ Geocache* gc_data = wpt_tmp->AllocGCData();
if (attr.hasAttribute(QLatin1String("id"))) {
gc_data->id = attr.value(QLatin1String(QLatin1String("id"))).toLongLong();
}
if (attr.hasAttribute(QLatin1String("available"))) {
if (attr.value(QLatin1String("available")).compare(QLatin1String("True"), Qt::CaseInsensitive) == 0) {
- gc_data->is_available = status_true;
+ gc_data->is_available = Geocache::status_t::gs_true;
} else if (attr.value(QLatin1String("available")).compare(QLatin1String("False"), Qt::CaseInsensitive) == 0) {
- gc_data->is_available = status_false;
+ gc_data->is_available = Geocache::status_t::gs_false;
}
}
if (attr.hasAttribute(QLatin1String("archived"))) {
if (attr.value(QLatin1String("archived")).compare(QLatin1String("True"), Qt::CaseInsensitive) == 0) {
- gc_data->is_archived = status_true;
+ gc_data->is_archived = Geocache::status_t::gs_true;
} else if (attr.value(QLatin1String("archived")).compare(QLatin1String("False"), Qt::CaseInsensitive) == 0) {
- gc_data->is_archived = status_false;
+ gc_data->is_archived = Geocache::status_t::gs_false;
}
}
}
}
}
-struct
- gs_type_mapping {
- geocache_type type;
- const char* name;
-} gs_type_map[] = {
- { gt_traditional, "Traditional Cache" },
- { gt_traditional, "Traditional" }, /* opencaching.de */
- { gt_multi, "Multi-cache" },
- { gt_multi, "Multi" }, /* opencaching.de */
- { gt_virtual, "Virtual Cache" },
- { gt_virtual, "Virtual" }, /* opencaching.de */
- { gt_event, "Event Cache" },
- { gt_event, "Event" }, /* opencaching.de */
- { gt_webcam, "Webcam Cache" },
- { gt_webcam, "Webcam" }, /* opencaching.de */
- { gt_surprise, "Unknown Cache" },
- { gt_earth, "Earthcache" },
- { gt_earth, "Earth" }, /* opencaching.de */
- { gt_cito, "Cache In Trash Out Event" },
- { gt_letterbox, "Letterbox Hybrid" },
- { gt_locationless, "Locationless (Reverse) Cache" },
- { gt_ape, "Project APE Cache" },
- { gt_mega, "Mega-Event Cache" },
- { gt_wherigo, "Wherigo Cache" },
-
- { gt_benchmark, "Benchmark" }, /* Not Groundspeak; for GSAK */
-};
-
-struct
- gs_container_mapping {
- geocache_container type;
- const char* name;
-} gs_container_map[] = {
- { gc_other, "Unknown" },
- { gc_other, "Other" }, /* Synonym on read. */
- { gc_micro, "Micro" },
- { gc_regular, "Regular" },
- { gc_large, "Large" },
- { gc_small, "Small" },
- { gc_virtual, "Virtual" }
-};
-
-geocache_type
-gs_mktype(const QString& t)
-{
- int sz = sizeof(gs_type_map) / sizeof(gs_type_map[0]);
-
- for (int i = 0; i < sz; i++) {
- if (!t.compare(gs_type_map[i].name,Qt::CaseInsensitive)) {
- return gs_type_map[i].type;
- }
- }
- return gt_unknown;
-}
-
-QString
-gs_get_cachetype(geocache_type t)
-{
- int sz = sizeof(gs_type_map) / sizeof(gs_type_map[0]);
-
- for (int i = 0; i < sz; i++) {
- if (t == gs_type_map[i].type) {
- return gs_type_map[i].name;
- }
- }
- return "Unknown";
-}
-
-geocache_container
-gs_mkcont(const QString& t)
-{
- int sz = sizeof(gs_container_map) / sizeof(gs_container_map[0]);
-
- for (int i = 0; i < sz; i++) {
- if (!t.compare(gs_container_map[i].name,Qt::CaseInsensitive)) {
- return gs_container_map[i].type;
- }
- }
- return gc_unknown;
-}
-
-QString
-gs_get_container(geocache_container t)
-{
- int sz = sizeof(gs_container_map) / sizeof(gs_container_map[0]);
-
- for (int i = 0; i < sz; i++) {
- if (t == gs_container_map[i].type) {
- return gs_container_map[i].name;
- }
- }
- return "Unknown";
-}
-
gpsbabel::DateTime
xml_parse_time(const QString& dateTimeString)
{
wpt_tmp->notes = cdatastr;
break;
case tt_cache_container:
- wpt_tmp->AllocGCData()->container = gs_mkcont(cdatastr);
+ wpt_tmp->AllocGCData()->set_container(cdatastr);
break;
case tt_cache_type:
- wpt_tmp->AllocGCData()->type = gs_mktype(cdatastr);
+ wpt_tmp->AllocGCData()->set_type(cdatastr);
break;
case tt_cache_difficulty:
wpt_tmp->AllocGCData()->diff = cdatastr.toFloat() * 10;
wpt_tmp->AllocGCData()->hint = cdatastr;
break;
case tt_cache_desc_long: {
- geocache_data* gc_data = wpt_tmp->AllocGCData();
+ Geocache* gc_data = wpt_tmp->AllocGCData();
gc_data->desc_long.is_html = cache_descr_is_html;
- gc_data->desc_long.utfstring = cdatastr;
+ gc_data->desc_long.utf_string = cdatastr;
}
break;
case tt_cache_desc_short: {
- geocache_data* gc_data = wpt_tmp->AllocGCData();
+ Geocache* gc_data = wpt_tmp->AllocGCData();
gc_data->desc_short.is_html = cache_descr_is_html;
- gc_data->desc_short.utfstring = cdatastr;
+ gc_data->desc_short.utf_string = cdatastr;
}
break;
case tt_cache_terrain:
#ifndef GPX_H_INCLUDED_
#define GPX_H_INCLUDED_
-#include <QHash> // for QHash
-#include <QString> // for QString
-#include <QStringList> // for QStringList
-#include <QStringView> // for QStringView
-#include <QVector> // for QVector
-#include <QVersionNumber> // for QVersionNumber
-#include <QXmlStreamAttributes> // for QXmlStreamAttributes
-#include <QXmlStreamReader> // for QXmlStreamReader
+#include <QHash> // for QHash
+#include <QList> // for QList
+#include <QString> // for QString
+#include <QStringList> // for QStringList
+#include <QStringView> // for QStringView
+#include <QVector> // for QVector
+#include <QVersionNumber> // for QVersionNumber
+#include <QXmlStreamAttributes> // for QXmlStreamAttributes
+#include <QXmlStreamReader> // for QXmlStreamReader
#include "defs.h"
-#include "format.h" // for Format
-#include "formspec.h" // for FormatSpecificData
-#include "src/core/file.h" // for File
-#include "src/core/xmlstreamwriter.h" // for XmlStreamWriter
-#include "src/core/xmltag.h" // for xml_tag
+#include "format.h" // for Format
+#include "formspec.h" // for FormatSpecificData
+#include "src/core/file.h" // for File
+#include "src/core/xmlstreamwriter.h" // for XmlStreamWriter
+#include "src/core/xmltag.h" // for xml_tag
class GpxFormat : public Format
#include "defs.h"
#include "formspec.h" // for FormatSpecificDataList, kFsGpx
+#include "geocache.h" // for Geocache, Geocache::UtfString
#include "jeeps/gpsmath.h" // for GPS_Math_WGS84_To_UTM_EN
#include "src/core/datetime.h" // for DateTime
#include "src/core/textstream.h" // for TextStream
.arg((wpt->gc_data->diff%10) ? "½" : "")
.arg((int)(wpt->gc_data->terr / 10))
.arg((wpt->gc_data->terr%10) ? "½" : "");
- *file_out << gs_get_cachetype(wpt->gc_data->type) << " / "
- << gs_get_container(wpt->gc_data->container) << "</p>\n";
+ *file_out << wpt->gc_data->get_type() << " / "
+ << wpt->gc_data->get_container() << "</p>\n";
}
*file_out << " </td>\n";
*file_out << " </tr>\n";
*file_out << " <tr>\n";
*file_out << " <td colspan=\"2\">\n";
- if (!wpt->gc_data->desc_short.utfstring.isEmpty()) {
+ if (!wpt->gc_data->desc_short.utf_string.isEmpty()) {
*file_out << " <div><p class=\"gpsbabeldescshort\">"
- << strip_nastyhtml(wpt->gc_data->desc_short.utfstring) << "</div>\n";
+ << strip_nastyhtml(wpt->gc_data->desc_short.utf_string) << "</div>\n";
}
- if (!wpt->gc_data->desc_long.utfstring.isEmpty()) {
+ if (!wpt->gc_data->desc_long.utf_string.isEmpty()) {
*file_out << " <div><p class=\"gpsbabeldesclong\">"
- << strip_nastyhtml(wpt->gc_data->desc_long.utfstring) << "</div>\n";
+ << strip_nastyhtml(wpt->gc_data->desc_long.utf_string) << "</div>\n";
}
if (!wpt->gc_data->hint.isEmpty()) {
QString hint;
*/
-#include <cctype> // for tolower, toupper
-#include <cmath> // for fabs
-#include <cstdio> // for sscanf, printf
-#include <cstdlib> // for strtod
-#include <cstring> // for strcmp
-#include <optional> // for optional
-#include <tuple> // for tuple, make_tuple
-
-#include <QByteArray> // for QByteArray
-#include <QChar> // for QChar
-#include <QDate> // for QDate
-#include <QDateTime> // for QDateTime
-#include <QFile> // for QFile
-#include <QIODevice> // for operator|, QIODevice, QIODevice::Text, QIODevice::WriteOnly
-#include <QList> // for QList
-#include <QString> // for QString, QStringLiteral, operator+, operator!=
-#include <QStringList> // for QStringList
-#include <QVector> // for QVector
-#include <QXmlStreamAttributes> // for QXmlStreamAttributes
-#include <Qt> // for ISODate
-#include <QtGlobal> // for foreach, qint64, qRound, qPrintable
+#include "kml.h"
+
+#include <cctype> // for tolower, toupper
+#include <cmath> // for fabs
+#include <cstdio> // for sscanf, printf
+#include <cstdlib> // for strtod
+#include <cstring> // for strcmp
+#include <optional> // for optional
+#include <tuple> // for tuple, make_tuple
+
+#include <QByteArray> // for QByteArray
+#include <QChar> // for QChar
+#include <QDate> // for QDate
+#include <QDateTime> // for QDateTime
+#include <QFile> // for QFile
+#include <QIODevice> // for operator|, QIODevice, QIODevice::Text, QIODevice::WriteOnly
+#include <QList> // for QList
+#include <QString> // for QString, QStringLiteral, operator+, operator!=
+#include <QStringList> // for QStringList
+#include <QVector> // for QVector
+#include <QXmlStreamAttributes> // for QXmlStreamAttributes
+#include <Qt> // for ISODate
+#include <QtGlobal> // for foreach, qint64, qRound, qPrintable
#include "defs.h"
-#include "kml.h"
-#include "formspec.h" // for FsChainFind, kFsGpx
-#include "grtcirc.h" // for RAD, gcdist, radtometers
-#include "src/core/datetime.h" // for DateTime
-#include "src/core/file.h" // for File
-#include "src/core/logging.h" // for Warning, Fatal
-#include "src/core/xmlstreamwriter.h" // for XmlStreamWriter
-#include "src/core/xmltag.h" // for xml_findfirst, xml_tag, fs_xml, xml_attribute, xml_findnext
-#include "units.h" // for fmt_setunits, fmt_speed, fmt_altitude, fmt_distance, units_aviation, units_metric, units_nautical, units_statute
-#include "xmlgeneric.h" // for cb_cdata, cb_end, cb_start, xg_callback, xg_string, xg_cb_type, xml_deinit, xml_ignore_tags, xml_init, xml_read, xg_tag_mapping
+#include "formspec.h" // for FsChainFind, kFsGpx
+#include "geocache.h" // for Geocache, Geocache::type_t
+#include "grtcirc.h" // for RAD, gcdist, radtometers
+#include "src/core/datetime.h" // for DateTime
+#include "src/core/file.h" // for File
+#include "src/core/logging.h" // for Warning, Fatal
+#include "src/core/xmlstreamwriter.h" // for XmlStreamWriter
+#include "src/core/xmltag.h" // for xml_findfirst, xml_tag, fs_xml, xml_attribute, xml_findnext
+#include "units.h" // for fmt_setunits, fmt_speed, fmt_altitude, fmt_distance, units_aviation, units_metric, units_nautical, units_statute
+#include "xmlgeneric.h" // for cb_cdata, cb_end, cb_start, xg_callback, xg_string, xg_cb_type, xml_deinit, xml_ignore_tags, xml_init, xml_read, xg_tag_mapping
// Icons provided and hosted by Google. Used with permission.
* initializers...
*/
switch (waypointp->gc_data->type) {
- case gt_traditional:
+ case Geocache::type_t::gt_traditional:
icon = "2.png";
break;
- case gt_multi:
+ case Geocache::type_t::gt_multi:
icon = "3.png";
break;
- case gt_virtual:
+ case Geocache::type_t::gt_virtual:
icon = "4.png";
break;
- case gt_letterbox:
+ case Geocache::type_t::gt_letterbox:
icon = "5.png";
break;
- case gt_event:
+ case Geocache::type_t::gt_event:
icon = "6.png";
break;
- case gt_ape:
+ case Geocache::type_t::gt_ape:
icon = "7.png";
break;
- case gt_locationless:
+ case Geocache::type_t::gt_locationless:
icon = "8.png";
break; // No unique icon.
- case gt_surprise:
+ case Geocache::type_t::gt_surprise:
icon = "8.png";
break;
- case gt_webcam:
+ case Geocache::type_t::gt_webcam:
icon = "11.png";
break;
- case gt_cito:
+ case Geocache::type_t::gt_cito:
icon = "13.png";
break;
- case gt_earth:
+ case Geocache::type_t::gt_earth:
icon = "earthcache.png";
break;
- case gt_mega:
+ case Geocache::type_t::gt_mega:
icon = "453.png";
break;
- case gt_wherigo:
+ case Geocache::type_t::gt_wherigo:
icon = "1858.png";
break;
default:
const char* cont;
switch (waypointp->gc_data->container) {
- case gc_micro:
+ case Geocache::container_t::gc_micro:
cont="micro";
break;
- case gc_regular:
+ case Geocache::container_t::gc_regular:
cont="regular";
break;
- case gc_large:
+ case Geocache::container_t::gc_large:
cont="large";
break;
- case gc_small:
+ case Geocache::container_t::gc_small:
cont="small";
break;
- case gc_virtual:
+ case Geocache::container_t::gc_virtual:
cont="virtual";
break;
- case gc_other:
+ case Geocache::container_t::gc_other:
cont="other";
break;
default:
// Highlight any issues with the cache, such as temp unavail
// or archived.
- if (waypointp->gc_data->is_archived == status_true) {
+ if (waypointp->gc_data->is_archived == Geocache::status_t::gs_true) {
issues = "<font color=\"red\">This cache has been archived.</font><br/>\n";
- } else if (waypointp->gc_data->is_available == status_false) {
+ } else if (waypointp->gc_data->is_available == Geocache::status_t::gs_false) {
issues = "<font color=\"red\">This cache is temporarily unavailable.</font><br/>\n";
}
kml_write_data_element("gc_issues", issues);
kml_write_data_element("gc_lat", waypointp->latitude);
kml_write_data_element("gc_lon", waypointp->longitude);
- kml_write_data_element("gc_type", gs_get_cachetype(waypointp->gc_data->type));
+ kml_write_data_element("gc_type", waypointp->gc_data->get_type());
kml_write_data_element("gc_icon", is);
- kml_write_cdata_element("gc_short_desc", waypointp->gc_data->desc_short.utfstring);
- kml_write_cdata_element("gc_long_desc", waypointp->gc_data->desc_long.utfstring);
+ kml_write_cdata_element("gc_short_desc", waypointp->gc_data->desc_short.utf_string);
+ kml_write_cdata_element("gc_long_desc", waypointp->gc_data->desc_long.utf_string);
QString logs = kml_geocache_get_logs(waypointp);
kml_write_cdata_element("gc_logs", logs);
*/
-#include <cinttypes> // for PRId64
-#include <cmath> // for M_PI, round, atan, exp, log, tan
-#include <cstdio> // for printf, sprintf, SEEK_CUR
-#include <cstdint> // for int64_t
-#include <cstdlib> // for abs
-#include <cstring> // for strcmp, strlen
-
-#include <QByteArray> // for QByteArray
-#include <QDate> // for QDate
-#include <QDateTime> // for QDateTime
-#include <QLatin1String> // for QLatin1String
-#include <QList> // for QList
-#include <QScopedPointer> // for QScopedPointer
-#include <QString> // for QString, operator+, operator==, operator!=
-#include <QTextCodec> // for QTextCodec, QTextCodec::IgnoreHeader
-#include <QTextEncoder> // for QTextEncoder
-#include <QTime> // for QTime
-#include <Qt> // for CaseInsensitive, UTC
-#include <QtGlobal> // for qPrintable, uint, qAsConst, QAddConst<>::Type
+#include "lowranceusr.h"
+
+#include <cinttypes> // for PRId64
+#include <cmath> // for M_PI, round, atan, exp, log, tan
+#include <cstdio> // for printf, sprintf, SEEK_CUR
+#include <cstdint> // for int64_t
+#include <cstdlib> // for abs
+#include <cstring> // for strcmp, strlen
+
+#include <QByteArray> // for QByteArray
+#include <QDate> // for QDate
+#include <QDateTime> // for QDateTime
+#include <QList> // for QList
+#include <QScopedPointer> // for QScopedPointer
+#include <QString> // for QString, operator+, operator==, operator!=
+#include <QTextCodec> // for QTextCodec, QTextCodec::IgnoreHeader
+#include <QTextEncoder> // for QTextEncoder
+#include <QTime> // for QTime
+#include <Qt> // for CaseInsensitive, UTC
+#include <QtGlobal> // for qPrintable, uint, qAsConst, QAddConst<>::Type
#include "defs.h"
-#include "lowranceusr.h"
-#include "formspec.h" // for FsChainFind, FsChainAdd, kFsLowranceusr4, FormatSpecificData
-#include "gbfile.h" // for gbfgetint32, gbfputint32, gbfputint16, gbfgetc, gbfgetint16, gbfwrite, gbfputc, gbfeof, gbfgetflt, gbfclose, gbfgetdbl, gbfopen_le, gbfputdbl, gbfputs, gbfile, gbfputflt, gbfread, gbfseek
-#include "src/core/datetime.h" // for DateTime
-#include "src/core/logging.h" // for Warning
+#include "formspec.h" // for FsChainFind, FsChainAdd, kFsLowranceusr4, FormatSpecificData
+#include "gbfile.h" // for gbfgetint32, gbfputint32, gbfputint16, gbfgetc, gbfgetint16, gbfwrite, gbfputc, gbfeof, gbfgetflt, gbfclose, gbfgetdbl, gbfopen_le, gbfputdbl, gbfputs, gbfile, gbfputflt, gbfread, gbfseek
+#include "geocache.h" // for Geocache, Geocache::status_t, Geocach...
+#include "src/core/datetime.h" // for DateTime
+#include "src/core/logging.h" // for Warning
/* from waypt.c, we need to iterate over waypoints when extracting routes */
gbfputint32(waypt_time, file_out);
- if (!get_cache_icon(wpt).isEmpty() && wpt->icon_descr.compare(u"Geocache Found") == 0) {
- SymbolId = lowranceusr_find_icon_number_from_desc(get_cache_icon(wpt));
+ if (!wpt->gc_data->get_icon().isEmpty() && wpt->icon_descr.compare(u"Geocache Found") == 0) {
+ SymbolId = lowranceusr_find_icon_number_from_desc(wpt->gc_data->get_icon());
} else {
SymbolId = lowranceusr_find_icon_number_from_desc(wpt->icon_descr);
}
/* If the waypoint is archived or disabled, use a "disabled" icon instead. */
- if ((wpt->gc_data->is_archived==status_true) || (wpt->gc_data->is_available==status_false)) {
+ if ((wpt->gc_data->is_archived == Geocache::status_t::gs_true) ||
+ (wpt->gc_data->is_available == Geocache::status_t::gs_false)) {
SymbolId = lowranceusr_find_icon_number_from_desc(DISABLED_CACHE_TXT);
}
gbfputint32(2, file_out);
int SymbolId, ColorId;
- if (!get_cache_icon(wpt).isEmpty() && wpt->icon_descr.compare(u"Geocache Found") == 0) {
+ if (!wpt->gc_data->get_icon().isEmpty() && wpt->icon_descr.compare(u"Geocache Found") == 0) {
if (writing_version == 4) {
SymbolId = lowranceusr4_find_icon_number_from_desc(wpt->icon_descr);
} else {
- SymbolId = lowranceusr_find_icon_number_from_desc(get_cache_icon(wpt));
+ SymbolId = lowranceusr_find_icon_number_from_desc(wpt->gc_data->get_icon());
}
ColorId = 0; // default
} else {
}
}
/* If the waypoint is archived or disabled, use a "disabled" icon instead. */
- if ((wpt->gc_data->is_archived==status_true) || (wpt->gc_data->is_available==status_false)) {
+ if ((wpt->gc_data->is_archived == Geocache::status_t::gs_true) ||
+ (wpt->gc_data->is_available == Geocache::status_t::gs_false)) {
SymbolId = lowranceusr_find_icon_number_from_desc(DISABLED_CACHE_TXT);
ColorId = 0; // default
}
#include <QtGlobal> // for foreach
#include "defs.h"
+#include "geocache.h" // for Geocache
#define MYNAME "mkshort"
QString
OsmFormat::osm_strip_html(const QString& str)
{
- utf_string utf(true, str);
- return strip_html(&utf); // util.cc
+ return strip_html(str); // util.cc
}
void
*/
+#include "sort.h"
+
#include <QDateTime> // for QDateTime
#include <QString> // for operator<, QString
#include "defs.h"
+#include "geocache.h" // for Geocache
#include "src/core/datetime.h" // for DateTime
-#include "sort.h"
+
#if FILTERS_ENABLED
#define MYNAME "sort"
#ifndef SORT_H_INCLUDED_
#define SORT_H_INCLUDED_
-#include <QVector> // for QVector
+#include <QString> // for QString
+#include <QVector> // for QVector
#include "defs.h" // for ARGTYPE_BOOL, ARG_NOMINMAX, arglist_t, ARG_TERMI...
#include "filter.h" // for Filter
#include "defs.h"
#include "formspec.h" // for FormatSpecificDataList, kFsGpx
+#include "geocache.h" // for Geocache, Geocache::UtfString
#include "jeeps/gpsmath.h" // for GPS_Math_WGS84_To_UTM_EN
#include "src/core/datetime.h" // for DateTime
#include "src/core/textstream.h" // for TextStream
}
if (wpt->gc_data->terr) {
*file_out << QStringLiteral(" - %1 / %2 - (%3%4 / %5%6)\n")
- .arg(gs_get_cachetype(wpt->gc_data->type),
- gs_get_container(wpt->gc_data->container))
+ .arg(wpt->gc_data->get_type(),
+ wpt->gc_data->get_container())
.arg((int)(wpt->gc_data->diff / 10))
.arg((wpt->gc_data->diff%10) ? ".5" : "")
.arg((int)(wpt->gc_data->terr / 10))
.arg((wpt->gc_data->terr%10) ? ".5" : "");
- if (!wpt->gc_data->desc_short.utfstring.isEmpty()) {
- *file_out << "\n" << strip_html(&wpt->gc_data->desc_short) << "\n";
+ if (!wpt->gc_data->desc_short.utf_string.isEmpty()) {
+ *file_out << "\n" << wpt->gc_data->desc_short.strip_html() << "\n";
}
- if (!wpt->gc_data->desc_long.utfstring.isEmpty()) {
- *file_out << "\n" << strip_html(&wpt->gc_data->desc_long) << "\n";
+ if (!wpt->gc_data->desc_long.utf_string.isEmpty()) {
+ *file_out << "\n" << wpt->gc_data->desc_long.strip_html() << "\n";
}
if (!wpt->gc_data->hint.isEmpty()) {
QString hint;
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#include "unicsv.h"
+
#include <cmath> // for fabs, lround
#include <cstdio> // for NULL, sscanf
-#include <cstdint>
#include <cstring> // for memset, strchr, strncpy
#include <ctime> // for gmtime
#include <QDateTime> // for QDateTime
#include <QIODevice> // for QIODevice, QIODevice::ReadOnly, QIODevice::WriteOnly
#include <QLatin1Char> // for QLatin1Char
-#include <QLatin1String> // for QLatin1String
#include <QString> // for QString, operator!=, operator==
#include <QStringList> // for QStringList
#include <QTextStream> // for QTextStream, operator<<, qSetRealNumberPrecision, qSetFieldWidth, QTextStream::FixedNotation
#include <QtGlobal> // for qPrintable
#include "defs.h"
-#include "unicsv.h"
#include "csv_util.h" // for csv_linesplit, human_to_dec
#include "formspec.h" // for FormatSpecificDataList
#include "garmin_fs.h" // for garmin_fs_flags_t, garmin_fs_t, GMSD_GET, GMSD_HAS, GMSD_SETQSTR, GMSD_FIND, garmin_fs_alloc
#include "garmin_tables.h" // for gt_lookup_datum_index, gt_get_mps_grid_longname, gt_lookup_grid_type
+#include "geocache.h" // for Geocache, Geocache::status_t, Geoc...
#include "jeeps/gpsmath.h" // for GPS_Math_UKOSMap_To_WGS84_M, GPS_Math_EN_To_UKOSNG_Map, GPS_Math_Known_Datum_To_UTM_EN, GPS_Math_Known_Datum_To_WGS84_M, GPS_Math_Swiss_EN_To_WGS84, GPS_Math_UTM_EN_To_Known_Datum, GPS_Math_WGS84_To_Known_Datum_M, GPS_Math_WGS84_To_Swiss_EN, GPS_Math_WGS...
#include "session.h" // for session_t
#include "src/core/datetime.h" // for DateTime
return unicsv_parse_time(CSTR(str), msec, date);
}
-status_type
+Geocache::status_t
UnicsvFormat::unicsv_parse_status(const QString& str)
{
if (str.compare(u"true", Qt::CaseInsensitive) == 0 ||
str.compare(u"yes", Qt::CaseInsensitive) == 0 ||
str == '1') {
- return status_true;
+ return Geocache::status_t::gs_true;
}
if (str.compare(u"false", Qt::CaseInsensitive) == 0 ||
str.compare(u"no", Qt::CaseInsensitive) == 0 ||
str == '0') {
- return status_false;
+ return Geocache::status_t::gs_false;
}
- return status_unknown;
+ return Geocache::status_t::gs_unknown;
}
QDateTime
int src_datum = unicsv_datum_idx;
int ns = 1;
int ew = 1;
- geocache_data* gc_data = nullptr;
+ Geocache* gc_data = nullptr;
auto* wpt = new Waypoint;
wpt->latitude = kUnicsvUnknown;
wpt->longitude = kUnicsvUnknown;
}
break;
case fld_gc_type:
- gc_data->type = gs_mktype(value);
+ gc_data->set_type(value);
break;
case fld_gc_container:
- gc_data->container = gs_mkcont(value);
+ gc_data->set_container(value);
break;
case fld_gc_terr:
gc_data->terr = value.toDouble() * 10;
}
if (! wpt->EmptyGCData()) {
- const geocache_data* gc_data = wpt->gc_data;
+ const Geocache* gc_data = wpt->gc_data;
if (gc_data->id) {
gb_setbit(&unicsv_outp_flags, fld_gc_id);
}
- if (gc_data->type) {
+ if (gc_data->type != Geocache::type_t::gt_unknown) {
gb_setbit(&unicsv_outp_flags, fld_gc_type);
}
- if (gc_data->container) {
+ if (gc_data->container != Geocache::container_t::gc_unknown) {
gb_setbit(&unicsv_outp_flags, fld_gc_container);
}
if (gc_data->terr) {
if (gc_data->diff) {
gb_setbit(&unicsv_outp_flags, fld_gc_diff);
}
- if (gc_data->is_archived) {
+ if (gc_data->is_archived != Geocache::status_t::gs_unknown) {
gb_setbit(&unicsv_outp_flags, fld_gc_is_archived);
}
- if (gc_data->is_available) {
+ if (gc_data->is_available != Geocache::status_t::gs_unknown) {
gb_setbit(&unicsv_outp_flags, fld_gc_is_available);
}
if (gc_data->exported.isValid()) {
UnicsvFormat::unicsv_waypt_disp_cb(const Waypoint* wpt)
{
double lat, lon, alt;
- const geocache_data* gc_data = nullptr;
+ const Geocache* gc_data = nullptr;
unicsv_waypt_ct++;
QString shortname = wpt->shortname;
}
if FIELD_USED(fld_gc_type) {
if (gc_data) {
- unicsv_print_str(gs_get_cachetype(gc_data->type));
+ unicsv_print_str(gc_data->get_type());
} else {
*fout << unicsv_fieldsep;
}
}
if FIELD_USED(fld_gc_container) {
if (gc_data) {
- unicsv_print_str(gs_get_container(gc_data->container));
+ unicsv_print_str(gc_data->get_container());
} else {
*fout << unicsv_fieldsep;
}
}
}
if FIELD_USED(fld_gc_is_archived) {
- if (gc_data && gc_data->is_archived) {
- unicsv_print_str((gc_data->is_archived == status_true) ? "True" : "False");
+ if (gc_data && (gc_data->is_archived != Geocache::status_t::gs_unknown)) {
+ unicsv_print_str((gc_data->is_archived == Geocache::status_t::gs_true) ? "True" : "False");
} else {
*fout << unicsv_fieldsep;
}
}
if FIELD_USED(fld_gc_is_available) {
- if (gc_data && gc_data->is_available) {
- unicsv_print_str((gc_data->is_available == status_true) ? "True" : "False");
+ if (gc_data && (gc_data->is_available != Geocache::status_t::gs_unknown)) {
+ unicsv_print_str((gc_data->is_available == Geocache::status_t::gs_true) ? "True" : "False");
} else {
*fout << unicsv_fieldsep;
}
#include "defs.h"
#include "format.h" // for Format
+#include "geocache.h" // for Geocache, Geocache::status_t
#include "src/core/textstream.h" // for TextStream
static time_t unicsv_parse_date(const char* str, int* consumed);
static time_t unicsv_parse_time(const char* str, int* usec, time_t* date);
static time_t unicsv_parse_time(const QString& str, int* msec, time_t* date);
- static status_type unicsv_parse_status(const QString& str);
+ static Geocache::status_t unicsv_parse_status(const QString& str);
QDateTime unicsv_adjust_time(time_t time, const time_t* date) const;
static bool unicsv_compare_fields(const QString& s, const field_t* f);
void unicsv_fondle_header(QString header);
return epoch.addMSecs(millisecs);
}
-/*
- * Return a pointer to a constant string that is suitable for icon lookup
- * based on geocache attributes. The strings used are those present in
- * a GPX file from geocaching.com. Thus we sort of make all the other
- * formats do lookups based on these strings.
- */
-QString
-get_cache_icon(const Waypoint* waypointp)
-{
- if (!global_opts.smart_icons) {
- return nullptr;
- }
-
- /*
- * For icons, type overwrites container. So a multi-micro will
- * get the icons for "multi".
- */
- switch (waypointp->gc_data->type) {
- case gt_virtual:
- return "Virtual cache";
- case gt_multi:
- return "Multi-Cache";
- case gt_event:
- return "Event Cache";
- case gt_surprise:
- return "Unknown Cache";
- case gt_webcam:
- return "Webcam Cache";
- default:
- break;
- }
-
- switch (waypointp->gc_data->container) {
- case gc_micro:
- return "Micro-Cache";
- break;
- default:
- break;
- }
-
- if (waypointp->gc_data->diff > 1) {
- return "Geocache";
- }
-
- return nullptr;
-}
-
double
endian_read_double(const void* ptr, int read_le)
{
* pleasant for a human reader. Yes, this falls down in all kinds of
* ways such as spaces within the tags, etc.
*/
-QString
-strip_html(const utf_string* in)
+QString strip_html(const QString& utfstring)
{
#if 0
// If we were willing to link core against QtGui (not out of the question)
// we could just do...and either decide whether to add handling for [IMG]
// or just say we don't do that any more.
QTextDocument doc;
- doc.setHtml(in->utfstring);
+ doc.setHtml(utfstring);
return doc.toPlainText().simplified();
#else
- if (!in->is_html) {
- return in->utfstring;
- }
-
char* out;
char* instr;
char tag[8];
unsigned short int taglen = 0;
- char* incopy = instr = xstrdup(in->utfstring);
+ char* incopy = instr = xstrdup(utfstring);
/*
* We only shorten, so just dupe the input buf for space.
*/
- char* outstring = out = xstrdup(in->utfstring);
+ char* outstring = out = xstrdup(utfstring);
tag[0] = 0;
while (*instr) {
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#include <cmath> // for fabs
-#include <cstdlib> // for abs
+#include <cmath> // for fabs
+#include <cstdlib> // for abs
-#include <QString> // for QString
-#include <QVector> // for QVector
-#include <Qt> // for CaseInsensitive
+#include <QString> // for QString
+#include <QVector> // for QVector
+#include <Qt> // for CaseInsensitive
#include "defs.h"
-#include "gbfile.h" // for gbfprintf, gbfputs, gbfclose, gbfopen, gbfile
+#include "gbfile.h" // for gbfprintf, gbfputs, gbfclose, gbfopen, gbfile
+#include "geocache.h" // for Geocache, Geocache::UtfString
static gbfile* file_out;
* newlines as we go.
*/
static void
-vcf_print_utf(const utf_string* s)
+vcf_print_utf(const Geocache::UtfString* s)
{
- if (!s) {
+ if (nullptr == s) {
return;
}
- QString stripped_html = strip_html(s);
+ QString stripped_html = s->strip_html();
stripped_html.replace("\n", "\\n", Qt::CaseInsensitive);
stripped_html.replace("<p>", "\\n", Qt::CaseInsensitive);
#include "defs.h"
#include "formspec.h" // for FormatSpecificDataList
#include "garmin_fs.h" // for garmin_ilink_t, garmin_fs_t
+#include "geocache.h" // for Geocache
#include "grtcirc.h" // for RAD, gcdist, heading_true_degrees, radtometers
#include "session.h" // for curr_session, session_t
#include "src/core/datetime.h" // for DateTime
WaypointList* global_waypoint_list;
-geocache_data Waypoint::empty_gc_data;
+Geocache Waypoint::empty_gc_data;
static global_trait traits;
const global_trait* get_traits()
{
// deep copy geocache data unless it is the special static empty_gc_data.
if (other.gc_data != &Waypoint::empty_gc_data) {
- gc_data = new geocache_data(*other.gc_data);
+ gc_data = new Geocache(*other.gc_data);
}
// deep copy fs chain data.
extra_data = rhs.extra_data;
// deep copy geocache data unless it is the special static empty_gc_data.
if (rhs.gc_data != &Waypoint::empty_gc_data) {
- gc_data = new geocache_data(*rhs.gc_data);
+ gc_data = new Geocache(*rhs.gc_data);
}
// deep copy fs chain data.
creation_time.setMSecsSinceEpoch((t * 1000) + ms);
}
-geocache_data*
+Geocache*
Waypoint::AllocGCData()
{
if (gc_data == &Waypoint::empty_gc_data) {
- gc_data = new geocache_data;
+ gc_data = new Geocache;
}
return gc_data;
}
*/
-#include <cassert> // for assert
-#include <cctype> // for isdigit, tolower
-#include <cmath> // for fabs, pow
-#include <cstdio> // for snprintf, sscanf
-#include <cstdlib> // for strtod
-#include <cstring> // for strlen, strncmp, strcmp, memset
-#include <ctime> // for gmtime, localtime, time_t, mktime, strftime
-#include <optional> // for optional
-
-#include <QByteArray> // for QByteArray
-#include <QChar> // for QChar
-#include <QDate> // for QDate
-#include <QDateTime> // for QDateTime
-#include <QDebug> // for QDebug
-#include <QHash> // for QHash
-#include <QIODevice> // for QIODevice, operator|, QIODevice::ReadOnly, QIODevice::Text, QIODevice::WriteOnly
-#include <QList> // for QList
-#include <QRegularExpression> // for QRegularExpression
-#include <QString> // for QString, operator+, operator==
-#include <QStringList> // for QStringList
-#include <QTextStream> // for QTextStream
-#include <QtGlobal> // for qAsConst, qRound, qPrintable
+#include "xcsv.h"
+
+#include <cctype> // for isdigit, tolower
+#include <cmath> // for fabs, pow
+#include <cstdio> // for snprintf, sscanf
+#include <cstdlib> // for strtod
+#include <cstring> // for strlen, strncmp, strcmp, memset
+#include <ctime> // for gmtime, localtime, time_t, mktime, strftime
+#include <optional> // for optional
+
+#include <QByteArray> // for QByteArray
+#include <QChar> // for QChar
+#include <QDate> // for QDate
+#include <QDateTime> // for QDateTime
+#include <QDebug> // for QDebug
+#include <QHash> // for QHash
+#include <QIODevice> // for QIODevice, operator|, QIODevice::ReadOnly, QIODevice::Text, QIODevice::WriteOnly
+#include <QList> // for QList
+#include <QRegularExpression> // for QRegularExpression
+#include <QString> // for QString, operator+, operator==
+#include <QStringList> // for QStringList
+#include <QTextStream> // for QTextStream
+#include <QtGlobal> // for qAsConst, qRound, qPrintable
#include "defs.h"
-#include "csv_util.h" // for csv_stringtrim, dec_to_human, csv_stringclean, human_to_dec, ddmmdir_to_degrees, dec_to_intdeg, decdir_to_dec, intdeg_to_dec, csv_linesplit
-#include "formspec.h" // for FormatSpecificDataList
-#include "garmin_fs.h" // for garmin_fs_t, garmin_fs_alloc
-#include "grtcirc.h" // for RAD, gcdist, radtometers
-#include "jeeps/gpsmath.h" // for GPS_Math_WGS84_To_UTM_EN, GPS_Lookup_Datum_Index, GPS_Math_Known_Datum_To_WGS84_M, GPS_Math_UTM_EN_To_Known_Datum, GPS_Math_WGS84_To_Known_Datum_M, GPS_Math_WGS84_To_UKOSMap_M
-#include "jeeps/gpsport.h" // for int32
-#include "session.h" // for session_t
-#include "src/core/datetime.h" // for DateTime
-#include "src/core/logging.h" // for FatalMsg
-#include "src/core/textstream.h" // for TextStream
-#include "strptime.h" // for strptime
-#include "xcsv.h"
+#include "csv_util.h" // for csv_stringtrim, dec_to_human, csv_stringclean, human_to_dec, ddmmdir_to_degrees, dec_to_intdeg, decdir_to_dec, intdeg_to_dec, csv_linesplit
+#include "formspec.h" // for FormatSpecificDataList
+#include "garmin_fs.h" // for garmin_fs_t, garmin_fs_alloc
+#include "geocache.h" // for Geocache, Geocache::status_t, Geoc...
+#include "grtcirc.h" // for RAD, gcdist, radtometers
+#include "jeeps/gpsmath.h" // for GPS_Math_WGS84_To_UTM_EN, GPS_Lookup_Datum_Index, GPS_Math_Known_Datum_To_WGS84_M, GPS_Math_UTM_EN_To_Known_Datum, GPS_Math_WGS84_To_Known_Datum_M, GPS_Math_WGS84_To_UKOSMap_M
+#include "jeeps/gpsport.h" // for int32
+#include "session.h" // for session_t
+#include "src/core/datetime.h" // for DateTime
+#include "src/core/logging.h" // for FatalMsg
+#include "src/core/textstream.h" // for TextStream
+#include "strptime.h" // for strptime
#if CSVFMTS_ENABLED
xcsv_parse_data* parse_data, const int line_no)
{
QString enclosure = "";
- geocache_data* gc_data = nullptr;
+ Geocache* gc_data = nullptr;
if (fmp.printfc.isNull()) {
fatal(MYNAME ": xcsv style '%s' is missing format specifier", fmp.key.constData());
break;
case XcsvStyle::XT_GEOCACHE_TYPE:
/* Geocache Type */
- wpt->AllocGCData()->type = gs_mktype(value);
+ wpt->AllocGCData()->set_type(value);
break;
case XcsvStyle::XT_GEOCACHE_CONTAINER:
- wpt->AllocGCData()->container = gs_mkcont(value);
+ wpt->AllocGCData()->set_container(value);
break;
case XcsvStyle::XT_GEOCACHE_HINT:
wpt->AllocGCData()->hint = value.trimmed();
case XcsvStyle::XT_GEOCACHE_ISAVAILABLE:
gc_data = wpt->AllocGCData();
if (value.trimmed().compare(u"False", Qt::CaseInsensitive) == 0) {
- gc_data->is_available = status_false;
+ gc_data->is_available = Geocache::status_t::gs_false;
} else if (value.trimmed().compare(u"True", Qt::CaseInsensitive) == 0) {
- gc_data->is_available = status_true;
+ gc_data->is_available = Geocache::status_t::gs_true;
} else {
- gc_data->is_available = status_unknown;
+ gc_data->is_available = Geocache::status_t::gs_unknown;
}
break;
case XcsvStyle::XT_GEOCACHE_ISARCHIVED:
gc_data = wpt->AllocGCData();
if (value.trimmed().compare(u"False", Qt::CaseInsensitive) == 0) {
- gc_data->is_archived = status_false;
+ gc_data->is_archived = Geocache::status_t::gs_false;
} else if (value.trimmed().compare(u"True", Qt::CaseInsensitive) == 0) {
- gc_data->is_archived = status_true;
+ gc_data->is_archived = Geocache::status_t::gs_true;
} else {
- gc_data->is_archived = status_unknown;
+ gc_data->is_archived = Geocache::status_t::gs_unknown;
}
break;
break;
case XcsvStyle::XT_GEOCACHE_CONTAINER:
/* Geocache Container */
- buff = QString::asprintf(fmp.printfc.constData(), CSTR(gs_get_container(wpt->gc_data->container)));
- field_is_unknown = wpt->gc_data->container == gc_unknown;
+ buff = QString::asprintf(fmp.printfc.constData(), CSTR(wpt->gc_data->get_container()));
+ field_is_unknown = wpt->gc_data->container == Geocache::container_t::gc_unknown;
break;
case XcsvStyle::XT_GEOCACHE_TYPE:
/* Geocache Type */
- buff = QString::asprintf(fmp.printfc.constData(), CSTR(gs_get_cachetype(wpt->gc_data->type)));
- field_is_unknown = wpt->gc_data->type == gt_unknown;
+ buff = QString::asprintf(fmp.printfc.constData(), CSTR(wpt->gc_data->get_type()));
+ field_is_unknown = wpt->gc_data->type == Geocache::type_t::gt_unknown;
break;
case XcsvStyle::XT_GEOCACHE_HINT:
buff = QString::asprintf(fmp.printfc.constData(), CSTR(wpt->gc_data->hint));
field_is_unknown = !wpt->gc_data->placer.isEmpty();
break;
case XcsvStyle::XT_GEOCACHE_ISAVAILABLE:
- if (wpt->gc_data->is_available == status_false) {
+ if (wpt->gc_data->is_available == Geocache::status_t::gs_false) {
buff = QString::asprintf(fmp.printfc.constData(), "False");
- } else if (wpt->gc_data->is_available == status_true) {
+ } else if (wpt->gc_data->is_available == Geocache::status_t::gs_true) {
buff = QString::asprintf(fmp.printfc.constData(), "True");
} else {
buff = QString::asprintf(fmp.printfc.constData(), "Unknown");
}
break;
case XcsvStyle::XT_GEOCACHE_ISARCHIVED:
- if (wpt->gc_data->is_archived == status_false) {
+ if (wpt->gc_data->is_archived == Geocache::status_t::gs_false) {
buff = QString::asprintf(fmp.printfc.constData(), "False");
- } else if (wpt->gc_data->is_archived == status_true) {
+ } else if (wpt->gc_data->is_archived == Geocache::status_t::gs_true) {
buff = QString::asprintf(fmp.printfc.constData(), "True");
} else {
buff = QString::asprintf(fmp.printfc.constData(), "Unknown");